package com.wqm.cn.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author wqm
*/
public class REPORT implements Serializable {

    private static final long serialVersionUID = 1607691496754L;


    /**
    * 主键
    * 报表ID
    * isNullAble:0
    */
    private Integer ID;

    /**
    * 报表名
    * isNullAble:0
    */
    private String rEPORTNAME;

    /**
    * 报表类型
    * isNullAble:0
    */
    private String rEPORTTYPE;

    /**
    * ExtJS 报表Group 字段
    * isNullAble:1
    */
    private String gROUPFIELD;

    /**
    * ExtJS报表Stack 字段
    * isNullAble:1
    */
    private String sTACKFIELD;

    /**
    * 数据源ID
    * isNullAble:0
    */
    private Integer dATAID;


    public void setID(Integer ID){this.ID = ID;}

    public Integer getID(){return this.ID;}

    public void setREPORTNAME(String rEPORTNAME){this.rEPORTNAME = rEPORTNAME;}

    public String getREPORTNAME(){return this.rEPORTNAME;}

    public void setREPORTTYPE(String rEPORTTYPE){this.rEPORTTYPE = rEPORTTYPE;}

    public String getREPORTTYPE(){return this.rEPORTTYPE;}

    public void setGROUPFIELD(String gROUPFIELD){this.gROUPFIELD = gROUPFIELD;}

    public String getGROUPFIELD(){return this.gROUPFIELD;}

    public void setSTACKFIELD(String sTACKFIELD){this.sTACKFIELD = sTACKFIELD;}

    public String getSTACKFIELD(){return this.sTACKFIELD;}

    public void setDATAID(Integer dATAID){this.dATAID = dATAID;}

    public Integer getDATAID(){return this.dATAID;}
    @Override
    public String toString() {
        return "REPORT{" +
                "ID='" + ID + '\'' +
                "rEPORTNAME='" + rEPORTNAME + '\'' +
                "rEPORTTYPE='" + rEPORTTYPE + '\'' +
                "gROUPFIELD='" + gROUPFIELD + '\'' +
                "sTACKFIELD='" + sTACKFIELD + '\'' +
                "dATAID='" + dATAID + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private REPORT set;

        private ConditionBuilder where;

        public UpdateBuilder set(REPORT set){
            this.set = set;
            return this;
        }

        public REPORT getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends REPORT{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> IDList;

        public List<Integer> getIDList(){return this.IDList;}

        private Integer IDSt;

        private Integer IDEd;

        public Integer getIDSt(){return this.IDSt;}

        public Integer getIDEd(){return this.IDEd;}

        private List<String> rEPORTNAMEList;

        public List<String> getREPORTNAMEList(){return this.rEPORTNAMEList;}


        private List<String> fuzzyREPORTNAME;

        public List<String> getFuzzyREPORTNAME(){return this.fuzzyREPORTNAME;}

        private List<String> rightFuzzyREPORTNAME;

        public List<String> getRightFuzzyREPORTNAME(){return this.rightFuzzyREPORTNAME;}
        private List<String> rEPORTTYPEList;

        public List<String> getREPORTTYPEList(){return this.rEPORTTYPEList;}


        private List<String> fuzzyREPORTTYPE;

        public List<String> getFuzzyREPORTTYPE(){return this.fuzzyREPORTTYPE;}

        private List<String> rightFuzzyREPORTTYPE;

        public List<String> getRightFuzzyREPORTTYPE(){return this.rightFuzzyREPORTTYPE;}
        private List<String> gROUPFIELDList;

        public List<String> getGROUPFIELDList(){return this.gROUPFIELDList;}


        private List<String> fuzzyGROUPFIELD;

        public List<String> getFuzzyGROUPFIELD(){return this.fuzzyGROUPFIELD;}

        private List<String> rightFuzzyGROUPFIELD;

        public List<String> getRightFuzzyGROUPFIELD(){return this.rightFuzzyGROUPFIELD;}
        private List<String> sTACKFIELDList;

        public List<String> getSTACKFIELDList(){return this.sTACKFIELDList;}


        private List<String> fuzzySTACKFIELD;

        public List<String> getFuzzySTACKFIELD(){return this.fuzzySTACKFIELD;}

        private List<String> rightFuzzySTACKFIELD;

        public List<String> getRightFuzzySTACKFIELD(){return this.rightFuzzySTACKFIELD;}
        private List<Integer> dATAIDList;

        public List<Integer> getDATAIDList(){return this.dATAIDList;}

        private Integer dATAIDSt;

        private Integer dATAIDEd;

        public Integer getDATAIDSt(){return this.dATAIDSt;}

        public Integer getDATAIDEd(){return this.dATAIDEd;}

        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder IDBetWeen(Integer IDSt,Integer IDEd){
            this.IDSt = IDSt;
            this.IDEd = IDEd;
            return this;
        }

        public QueryBuilder IDGreaterEqThan(Integer IDSt){
            this.IDSt = IDSt;
            return this;
        }
        public QueryBuilder IDLessEqThan(Integer IDEd){
            this.IDEd = IDEd;
            return this;
        }


        public QueryBuilder ID(Integer ID){
            setID(ID);
            return this;
        }

        public QueryBuilder IDList(Integer ... ID){
            this.IDList = solveNullList(ID);
            return this;
        }

        public QueryBuilder IDList(List<Integer> ID){
            this.IDList = ID;
            return this;
        }

        public QueryBuilder fetchID(){
            setFetchFields("fetchFields","ID");
            return this;
        }

        public QueryBuilder excludeID(){
            setFetchFields("excludeFields","ID");
            return this;
        }

        public QueryBuilder fuzzyREPORTNAME (List<String> fuzzyREPORTNAME){
            this.fuzzyREPORTNAME = fuzzyREPORTNAME;
            return this;
        }

        public QueryBuilder fuzzyREPORTNAME (String ... fuzzyREPORTNAME){
            this.fuzzyREPORTNAME = solveNullList(fuzzyREPORTNAME);
            return this;
        }

        public QueryBuilder rightFuzzyREPORTNAME (List<String> rightFuzzyREPORTNAME){
            this.rightFuzzyREPORTNAME = rightFuzzyREPORTNAME;
            return this;
        }

        public QueryBuilder rightFuzzyREPORTNAME (String ... rightFuzzyREPORTNAME){
            this.rightFuzzyREPORTNAME = solveNullList(rightFuzzyREPORTNAME);
            return this;
        }

        public QueryBuilder rEPORTNAME(String rEPORTNAME){
            setREPORTNAME(rEPORTNAME);
            return this;
        }

        public QueryBuilder rEPORTNAMEList(String ... rEPORTNAME){
            this.rEPORTNAMEList = solveNullList(rEPORTNAME);
            return this;
        }

        public QueryBuilder rEPORTNAMEList(List<String> rEPORTNAME){
            this.rEPORTNAMEList = rEPORTNAME;
            return this;
        }

        public QueryBuilder fetchREPORTNAME(){
            setFetchFields("fetchFields","rEPORTNAME");
            return this;
        }

        public QueryBuilder excludeREPORTNAME(){
            setFetchFields("excludeFields","rEPORTNAME");
            return this;
        }

        public QueryBuilder fuzzyREPORTTYPE (List<String> fuzzyREPORTTYPE){
            this.fuzzyREPORTTYPE = fuzzyREPORTTYPE;
            return this;
        }

        public QueryBuilder fuzzyREPORTTYPE (String ... fuzzyREPORTTYPE){
            this.fuzzyREPORTTYPE = solveNullList(fuzzyREPORTTYPE);
            return this;
        }

        public QueryBuilder rightFuzzyREPORTTYPE (List<String> rightFuzzyREPORTTYPE){
            this.rightFuzzyREPORTTYPE = rightFuzzyREPORTTYPE;
            return this;
        }

        public QueryBuilder rightFuzzyREPORTTYPE (String ... rightFuzzyREPORTTYPE){
            this.rightFuzzyREPORTTYPE = solveNullList(rightFuzzyREPORTTYPE);
            return this;
        }

        public QueryBuilder rEPORTTYPE(String rEPORTTYPE){
            setREPORTTYPE(rEPORTTYPE);
            return this;
        }

        public QueryBuilder rEPORTTYPEList(String ... rEPORTTYPE){
            this.rEPORTTYPEList = solveNullList(rEPORTTYPE);
            return this;
        }

        public QueryBuilder rEPORTTYPEList(List<String> rEPORTTYPE){
            this.rEPORTTYPEList = rEPORTTYPE;
            return this;
        }

        public QueryBuilder fetchREPORTTYPE(){
            setFetchFields("fetchFields","rEPORTTYPE");
            return this;
        }

        public QueryBuilder excludeREPORTTYPE(){
            setFetchFields("excludeFields","rEPORTTYPE");
            return this;
        }

        public QueryBuilder fuzzyGROUPFIELD (List<String> fuzzyGROUPFIELD){
            this.fuzzyGROUPFIELD = fuzzyGROUPFIELD;
            return this;
        }

        public QueryBuilder fuzzyGROUPFIELD (String ... fuzzyGROUPFIELD){
            this.fuzzyGROUPFIELD = solveNullList(fuzzyGROUPFIELD);
            return this;
        }

        public QueryBuilder rightFuzzyGROUPFIELD (List<String> rightFuzzyGROUPFIELD){
            this.rightFuzzyGROUPFIELD = rightFuzzyGROUPFIELD;
            return this;
        }

        public QueryBuilder rightFuzzyGROUPFIELD (String ... rightFuzzyGROUPFIELD){
            this.rightFuzzyGROUPFIELD = solveNullList(rightFuzzyGROUPFIELD);
            return this;
        }

        public QueryBuilder gROUPFIELD(String gROUPFIELD){
            setGROUPFIELD(gROUPFIELD);
            return this;
        }

        public QueryBuilder gROUPFIELDList(String ... gROUPFIELD){
            this.gROUPFIELDList = solveNullList(gROUPFIELD);
            return this;
        }

        public QueryBuilder gROUPFIELDList(List<String> gROUPFIELD){
            this.gROUPFIELDList = gROUPFIELD;
            return this;
        }

        public QueryBuilder fetchGROUPFIELD(){
            setFetchFields("fetchFields","gROUPFIELD");
            return this;
        }

        public QueryBuilder excludeGROUPFIELD(){
            setFetchFields("excludeFields","gROUPFIELD");
            return this;
        }

        public QueryBuilder fuzzySTACKFIELD (List<String> fuzzySTACKFIELD){
            this.fuzzySTACKFIELD = fuzzySTACKFIELD;
            return this;
        }

        public QueryBuilder fuzzySTACKFIELD (String ... fuzzySTACKFIELD){
            this.fuzzySTACKFIELD = solveNullList(fuzzySTACKFIELD);
            return this;
        }

        public QueryBuilder rightFuzzySTACKFIELD (List<String> rightFuzzySTACKFIELD){
            this.rightFuzzySTACKFIELD = rightFuzzySTACKFIELD;
            return this;
        }

        public QueryBuilder rightFuzzySTACKFIELD (String ... rightFuzzySTACKFIELD){
            this.rightFuzzySTACKFIELD = solveNullList(rightFuzzySTACKFIELD);
            return this;
        }

        public QueryBuilder sTACKFIELD(String sTACKFIELD){
            setSTACKFIELD(sTACKFIELD);
            return this;
        }

        public QueryBuilder sTACKFIELDList(String ... sTACKFIELD){
            this.sTACKFIELDList = solveNullList(sTACKFIELD);
            return this;
        }

        public QueryBuilder sTACKFIELDList(List<String> sTACKFIELD){
            this.sTACKFIELDList = sTACKFIELD;
            return this;
        }

        public QueryBuilder fetchSTACKFIELD(){
            setFetchFields("fetchFields","sTACKFIELD");
            return this;
        }

        public QueryBuilder excludeSTACKFIELD(){
            setFetchFields("excludeFields","sTACKFIELD");
            return this;
        }

        public QueryBuilder dATAIDBetWeen(Integer dATAIDSt,Integer dATAIDEd){
            this.dATAIDSt = dATAIDSt;
            this.dATAIDEd = dATAIDEd;
            return this;
        }

        public QueryBuilder dATAIDGreaterEqThan(Integer dATAIDSt){
            this.dATAIDSt = dATAIDSt;
            return this;
        }
        public QueryBuilder dATAIDLessEqThan(Integer dATAIDEd){
            this.dATAIDEd = dATAIDEd;
            return this;
        }


        public QueryBuilder dATAID(Integer dATAID){
            setDATAID(dATAID);
            return this;
        }

        public QueryBuilder dATAIDList(Integer ... dATAID){
            this.dATAIDList = solveNullList(dATAID);
            return this;
        }

        public QueryBuilder dATAIDList(List<Integer> dATAID){
            this.dATAIDList = dATAID;
            return this;
        }

        public QueryBuilder fetchDATAID(){
            setFetchFields("fetchFields","dATAID");
            return this;
        }

        public QueryBuilder excludeDATAID(){
            setFetchFields("excludeFields","dATAID");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public REPORT build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> IDList;

        public List<Integer> getIDList(){return this.IDList;}

        private Integer IDSt;

        private Integer IDEd;

        public Integer getIDSt(){return this.IDSt;}

        public Integer getIDEd(){return this.IDEd;}

        private List<String> rEPORTNAMEList;

        public List<String> getREPORTNAMEList(){return this.rEPORTNAMEList;}


        private List<String> fuzzyREPORTNAME;

        public List<String> getFuzzyREPORTNAME(){return this.fuzzyREPORTNAME;}

        private List<String> rightFuzzyREPORTNAME;

        public List<String> getRightFuzzyREPORTNAME(){return this.rightFuzzyREPORTNAME;}
        private List<String> rEPORTTYPEList;

        public List<String> getREPORTTYPEList(){return this.rEPORTTYPEList;}


        private List<String> fuzzyREPORTTYPE;

        public List<String> getFuzzyREPORTTYPE(){return this.fuzzyREPORTTYPE;}

        private List<String> rightFuzzyREPORTTYPE;

        public List<String> getRightFuzzyREPORTTYPE(){return this.rightFuzzyREPORTTYPE;}
        private List<String> gROUPFIELDList;

        public List<String> getGROUPFIELDList(){return this.gROUPFIELDList;}


        private List<String> fuzzyGROUPFIELD;

        public List<String> getFuzzyGROUPFIELD(){return this.fuzzyGROUPFIELD;}

        private List<String> rightFuzzyGROUPFIELD;

        public List<String> getRightFuzzyGROUPFIELD(){return this.rightFuzzyGROUPFIELD;}
        private List<String> sTACKFIELDList;

        public List<String> getSTACKFIELDList(){return this.sTACKFIELDList;}


        private List<String> fuzzySTACKFIELD;

        public List<String> getFuzzySTACKFIELD(){return this.fuzzySTACKFIELD;}

        private List<String> rightFuzzySTACKFIELD;

        public List<String> getRightFuzzySTACKFIELD(){return this.rightFuzzySTACKFIELD;}
        private List<Integer> dATAIDList;

        public List<Integer> getDATAIDList(){return this.dATAIDList;}

        private Integer dATAIDSt;

        private Integer dATAIDEd;

        public Integer getDATAIDSt(){return this.dATAIDSt;}

        public Integer getDATAIDEd(){return this.dATAIDEd;}


        public ConditionBuilder IDBetWeen(Integer IDSt,Integer IDEd){
            this.IDSt = IDSt;
            this.IDEd = IDEd;
            return this;
        }

        public ConditionBuilder IDGreaterEqThan(Integer IDSt){
            this.IDSt = IDSt;
            return this;
        }
        public ConditionBuilder IDLessEqThan(Integer IDEd){
            this.IDEd = IDEd;
            return this;
        }


        public ConditionBuilder IDList(Integer ... ID){
            this.IDList = solveNullList(ID);
            return this;
        }

        public ConditionBuilder IDList(List<Integer> ID){
            this.IDList = ID;
            return this;
        }

        public ConditionBuilder fuzzyREPORTNAME (List<String> fuzzyREPORTNAME){
            this.fuzzyREPORTNAME = fuzzyREPORTNAME;
            return this;
        }

        public ConditionBuilder fuzzyREPORTNAME (String ... fuzzyREPORTNAME){
            this.fuzzyREPORTNAME = solveNullList(fuzzyREPORTNAME);
            return this;
        }

        public ConditionBuilder rightFuzzyREPORTNAME (List<String> rightFuzzyREPORTNAME){
            this.rightFuzzyREPORTNAME = rightFuzzyREPORTNAME;
            return this;
        }

        public ConditionBuilder rightFuzzyREPORTNAME (String ... rightFuzzyREPORTNAME){
            this.rightFuzzyREPORTNAME = solveNullList(rightFuzzyREPORTNAME);
            return this;
        }

        public ConditionBuilder rEPORTNAMEList(String ... rEPORTNAME){
            this.rEPORTNAMEList = solveNullList(rEPORTNAME);
            return this;
        }

        public ConditionBuilder rEPORTNAMEList(List<String> rEPORTNAME){
            this.rEPORTNAMEList = rEPORTNAME;
            return this;
        }

        public ConditionBuilder fuzzyREPORTTYPE (List<String> fuzzyREPORTTYPE){
            this.fuzzyREPORTTYPE = fuzzyREPORTTYPE;
            return this;
        }

        public ConditionBuilder fuzzyREPORTTYPE (String ... fuzzyREPORTTYPE){
            this.fuzzyREPORTTYPE = solveNullList(fuzzyREPORTTYPE);
            return this;
        }

        public ConditionBuilder rightFuzzyREPORTTYPE (List<String> rightFuzzyREPORTTYPE){
            this.rightFuzzyREPORTTYPE = rightFuzzyREPORTTYPE;
            return this;
        }

        public ConditionBuilder rightFuzzyREPORTTYPE (String ... rightFuzzyREPORTTYPE){
            this.rightFuzzyREPORTTYPE = solveNullList(rightFuzzyREPORTTYPE);
            return this;
        }

        public ConditionBuilder rEPORTTYPEList(String ... rEPORTTYPE){
            this.rEPORTTYPEList = solveNullList(rEPORTTYPE);
            return this;
        }

        public ConditionBuilder rEPORTTYPEList(List<String> rEPORTTYPE){
            this.rEPORTTYPEList = rEPORTTYPE;
            return this;
        }

        public ConditionBuilder fuzzyGROUPFIELD (List<String> fuzzyGROUPFIELD){
            this.fuzzyGROUPFIELD = fuzzyGROUPFIELD;
            return this;
        }

        public ConditionBuilder fuzzyGROUPFIELD (String ... fuzzyGROUPFIELD){
            this.fuzzyGROUPFIELD = solveNullList(fuzzyGROUPFIELD);
            return this;
        }

        public ConditionBuilder rightFuzzyGROUPFIELD (List<String> rightFuzzyGROUPFIELD){
            this.rightFuzzyGROUPFIELD = rightFuzzyGROUPFIELD;
            return this;
        }

        public ConditionBuilder rightFuzzyGROUPFIELD (String ... rightFuzzyGROUPFIELD){
            this.rightFuzzyGROUPFIELD = solveNullList(rightFuzzyGROUPFIELD);
            return this;
        }

        public ConditionBuilder gROUPFIELDList(String ... gROUPFIELD){
            this.gROUPFIELDList = solveNullList(gROUPFIELD);
            return this;
        }

        public ConditionBuilder gROUPFIELDList(List<String> gROUPFIELD){
            this.gROUPFIELDList = gROUPFIELD;
            return this;
        }

        public ConditionBuilder fuzzySTACKFIELD (List<String> fuzzySTACKFIELD){
            this.fuzzySTACKFIELD = fuzzySTACKFIELD;
            return this;
        }

        public ConditionBuilder fuzzySTACKFIELD (String ... fuzzySTACKFIELD){
            this.fuzzySTACKFIELD = solveNullList(fuzzySTACKFIELD);
            return this;
        }

        public ConditionBuilder rightFuzzySTACKFIELD (List<String> rightFuzzySTACKFIELD){
            this.rightFuzzySTACKFIELD = rightFuzzySTACKFIELD;
            return this;
        }

        public ConditionBuilder rightFuzzySTACKFIELD (String ... rightFuzzySTACKFIELD){
            this.rightFuzzySTACKFIELD = solveNullList(rightFuzzySTACKFIELD);
            return this;
        }

        public ConditionBuilder sTACKFIELDList(String ... sTACKFIELD){
            this.sTACKFIELDList = solveNullList(sTACKFIELD);
            return this;
        }

        public ConditionBuilder sTACKFIELDList(List<String> sTACKFIELD){
            this.sTACKFIELDList = sTACKFIELD;
            return this;
        }

        public ConditionBuilder dATAIDBetWeen(Integer dATAIDSt,Integer dATAIDEd){
            this.dATAIDSt = dATAIDSt;
            this.dATAIDEd = dATAIDEd;
            return this;
        }

        public ConditionBuilder dATAIDGreaterEqThan(Integer dATAIDSt){
            this.dATAIDSt = dATAIDSt;
            return this;
        }
        public ConditionBuilder dATAIDLessEqThan(Integer dATAIDEd){
            this.dATAIDEd = dATAIDEd;
            return this;
        }


        public ConditionBuilder dATAIDList(Integer ... dATAID){
            this.dATAIDList = solveNullList(dATAID);
            return this;
        }

        public ConditionBuilder dATAIDList(List<Integer> dATAID){
            this.dATAIDList = dATAID;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private REPORT obj;

        public Builder(){
            this.obj = new REPORT();
        }

        public Builder ID(Integer ID){
            this.obj.setID(ID);
            return this;
        }
        public Builder rEPORTNAME(String rEPORTNAME){
            this.obj.setREPORTNAME(rEPORTNAME);
            return this;
        }
        public Builder rEPORTTYPE(String rEPORTTYPE){
            this.obj.setREPORTTYPE(rEPORTTYPE);
            return this;
        }
        public Builder gROUPFIELD(String gROUPFIELD){
            this.obj.setGROUPFIELD(gROUPFIELD);
            return this;
        }
        public Builder sTACKFIELD(String sTACKFIELD){
            this.obj.setSTACKFIELD(sTACKFIELD);
            return this;
        }
        public Builder dATAID(Integer dATAID){
            this.obj.setDATAID(dATAID);
            return this;
        }
        public REPORT build(){return obj;}
    }

}
